﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;

namespace Utility1
{
    class Send_email
    {
        private String email;
    private String title;
    private String content;
    public Send_email(string email, string title, string content)
	{
        this.email = email;
        this.title = title;
        this.content = content;
	}
    public Send_email()
    {

    }
    public Boolean sMail()
    {
        SmtpClient SmtpServer = new SmtpClient();
        SmtpServer.Credentials = new System.Net.NetworkCredential("msmart.infor@gmail.com", "nguyenthien321");
        SmtpServer.Port = 587;
        SmtpServer.Host = "smtp.gmail.com";
        SmtpServer.EnableSsl = true;
        MailMessage mail = new MailMessage();
        String[] addr = email.Split(',');
        try
        {
            mail.From = new MailAddress("msmart.infor@gmail.com", "http://msmart.vn", System.Text.Encoding.UTF8);
            Byte i;
            for (i = 0; i < addr.Length; i++)
                mail.To.Add(addr[i]);
            mail.Subject = title;
            mail.Body = content;
            mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
            mail.ReplyTo = new MailAddress(email);
            SmtpServer.Send(mail);
            return true;
        }
        catch (Exception)
        {
            return false;
        }
    }
    }
}
